from sqlalchemy import Column, Integer, String, DateTime, func, Text
from server.db.base import Base

class VoiceCloneTask(Base):
    """
    语音克隆任务模型
    """
    __tablename__ = "voice_clone_tasks"
    
    id = Column(Integer, primary_key=True, autoincrement=True, comment="自增ID")
    uid = Column(String(255), nullable=False, index=True, comment="用户ID")  # 修改字段名映射
    timbre_id = Column(String(255), nullable=False, unique=True, comment="音色ID")
    url = Column(Text, nullable=False, comment="音频URL")
    task_id = Column(String(255), nullable=False, unique=True, comment="任务ID")
    task_status = Column(String(50), default='pending', comment="任务状态")  # 修改字段名称
    created_at = Column(DateTime, server_default=func.now(), comment="创建时间")  # 修改默认值设置方式


    def __repr__(self):
        return f"<VoiceCloneTask(id={self.id}, uid='{self.uid}', timbre_id='{self.timbre_id}', url='{self.url}', task_id='{self.task_id}', task_status='{self.task_status}')>"

